function Tag({el,arrColor=["green", "red", "blue"]}) {
	this.el = document.querySelector(el);
	this.btns = this.el.querySelectorAll("button");
	this.divs = this.el.querySelectorAll("div");
	this.arrColor = arrColor;
	this.index = 0;
	this.init();
}

Object.assign(Tag.prototype, {
	init() {
		this.btns.forEach((btn, i)=> {
			btn.onclick = ()=> {
				if (this.index === i) return;
				this.hide();
				this.index = i;
				this.show();
			}
			// 隐藏div
			this.hide(i);
			
		})
		this.show();
	},
	hide(i = this.index) {
		this.btns[i].style.background = null;// 删除当前选中的按钮样式
		this.divs[i].style.display = "none";
	},
	show() {
		this.divs[this.index].style.background = this.btns[this.index].style.background = this.arrColor[this.index];
		this.divs[this.index].style.display = "block";
	}
})
